|
|
|
|
|
|
|
m3Identity M()
M(2, 2) = Cos(theta)
M(3, 3) = M(2, 2)
M(2, 3) = Sin(theta)
M(3, 2) = -M(2, 3)
End Sub |
|
|
|
 |
|
|
|
|
' Create a 3-D transformation matrix for rotation
' around the Y axis (angle measured in radians). Public Sub m3YRotate(M() As Single, ByVal theta As Single)
Dim i As Integer
m3Identity M()
M(1, 1) = Cos(theta)
M(3, 3) = M(1, 1)
M(3, 1) = Sin(theta)
M(1, 3) = -M(3, 1)
End Sub
' Create a 3-D transformation matrix for rotation
' around the Z axis (angle measured in radians). Public Sub m3ZRotate(M() As Single, ByVal theta As Single)
Dim i As Integer
m3Identity M()
M(1, 1) = Cos(theta)
M(2, 2) = M(1, 1)
M(1, 2) = Sin(theta)
M(2, 1) = -M(1, 2)
End Sub |
|
|
|
|
|
|
|
|
Sometimes it is more convenient to specify a rotation with a point that should be rotated until it lies in the XY, YZ, or XZ plane. This is no different from the two-dimensional case in which it was convenient to specify a rotation with a point that should be rotated into the X or Y axis. For example, rotating a point into the X-Z plane in three dimensions is equivalent to ignoring the point's Z coordinate and rotating the point into the X axis in two dimensions. |
|
|
|
|
|
|
|
|
Figure 13.3 shows a point that should be rotated around the Z axis until it lies in the XZ plane. The distance d is the distance from the projection of the point into the XY plane, to the origin. This distance equals Sqr(x * x + y * y). Because q is measured in the negative direction, Cos(q) = x/d and Sin(q) = y/d. Leaving the Z coordinate of the point unchanged, the rotation transformation matrix is: |
|
|
|
|
|